import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;

public class Demo6 {
    public static void main(String[] args) throws IOException {
//        InputStream inputStream = new FileInputStream("./test.txt");
//        while(true){
//            int n = inputStream.read();
//            if(n == -1){
//                break;
//            }
//            System.out.printf("0x%X",n);
//        }

//        while(true) {
//            byte[] bytes = new byte[1024];
//            int n = inputStream.read(bytes);
//            if(n == -1){
//                break;
//            }
//            for(int i = 0; i < n; i++){
//                System.out.printf("0x%X ",bytes[i]);
//            }
//        }
        //自动加上close
        try(InputStream inputStream = new FileInputStream("./test.txt")){
            while(true){
                byte[] bytes = new byte[1024];
                int n = inputStream.read(bytes);
                if(n == -1) break;
                for(int i = 0; i < n; i++){
                    System.out.printf("0x%X ",bytes[i]);
                }
            }
        }


    }
}
